<template>
  <e-table
    ref="eTable"
    @getList="handleGetList"
    :tableData="tableData"
    :columns="columns"
    :loading="loading"
    :pageObj="null"
  >
    <el-table-column slot="upAndLow" align="center" label="奖惩上限-下限" width="120">
      <template
        slot-scope="scope"
      >{{ scope.row.rewardUpLimit ? scope.row.rewardUpLimit : '无上限' }} - {{ scope.row.rewardLowLimit ? scope.row.rewardLowLimit : '无下限' }}</template>
    </el-table-column>
    <el-table-column slot="rewardType" align="center" label="奖惩形式" width="80">
      <template slot-scope="scope">{{ scope.row.rewardType === 1 ? '分' : '钱' }}</template>
    </el-table-column>
    <el-table-column slot="evalTarget" align="center" label="考评对象" width="80">
      <template slot-scope="scope">{{ scope.row.evalTarget === 1 ? '科室' : '个人' }}</template>
    </el-table-column>
  </e-table>
</template>

<script>
import { schemeDetail } from '@/api/eval'
export default {
  data() {
    return {
      columns: [
        {
          label: '考评分类',
          prop: 'evalTypeName'
        },
        {
          label: '项目名称',
          prop: 'evalItemName',
          tooltip: true
        },
        {
          label: '项目内容',
          prop: 'evalItemContent',
          tooltip: true
        },
        {
          label: '考核标准',
          prop: 'standard',
          tooltip: true,
          width: '150px'
        },
        { slot: 'rewardType' },
        { slot: 'upAndLow' },
        {
          label: '奖惩标准',
          prop: 'rewardStandard',
          width: '80px'
        },
        { slot: 'evalTarget' }
      ],
      tableData: [],
      loading: false,
      queryParam: {
        pageNo: 1,
        pageSize: 10
      }
    }
  },
  methods: {
    async handleGetList(param = {}) {
      this.loading = true
      const res = await itemQuery({ ...this.queryParam, ...param })
      if (res && res.data.records.length > 0) {
        const {
          state,
          data: { records, total }
        } = res
        this.tableData = records
        this.total = total
      } else {
        this.tableData = []
        this.total = 1
      }
      this.loading = false
    },
    detail(row) {
      console.log('row', row)
      schemeDetail(row.evalSchemeId, {}).then(res => {
        console.log('detail', res)
        this.tableData = res.data
      })
    }
  }
}
</script>
